<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\tool\Result;
use think\facade\View;
use think\response\Json;
use app\common\model\Enterprise as EnterpriseModel;
use think\exception\ValidateException;

class Enterprise extends Base
{

    public function save(): Json
    {
        $param = $this->request->param();
        try {
            $this->validate($param, 'Enterprise');
        } catch (ValidateException $e) {
            return json(['code' => -1, 'msg' => $e->getError()]);
        }
        return json(EnterpriseModel::add($param, $this->user));
    }


    function distance() {
        // 调用函数并输出结果
        $result = EnterpriseModel::distance(40.7128, -74.0060, 51.5074, -0.1278);
        return Result::success('获取数据成功！',$result);
    }



}

